package com.asia5b.a5mall.member.adapter

import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.asia5b.a5bmall.same.databinding.GoodsitemCollectBinding
import com.asia5b.a5mall.member.R
import com.asia5b.a5mall.member.databinding.ItemCollectShopAdapterBinding
import com.asia5b.a5mall.middleware.model.shop.AbsGoodsModel
import com.asia5b.a5mall.middleware.model.shop.AbsShopModel
import com.asia5b.a5mall.middleware.utils.CurrencyPriceBuilder3
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.chad.library.adapter.base.entity.MultiItemEntity
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder

/**
 * Created by zhangyuncai on 2020/1/10.
 */
class CollectAdapter(list: ArrayList<MultiItemEntity>) : BaseMultiItemQuickAdapter<MultiItemEntity, BaseDataBindingHolder<*>>(list) {
    var isShowDelete = false

    init {
        addItemType(0, R.layout.goodsitem_collect)
        addItemType(1, R.layout.item_collect_shop_adapter)

        addChildClickViewIds(R.id.cb_collect_goods_check)
        addChildClickViewIds(R.id.tv_collect_goods_delete)
        addChildClickViewIds(R.id.cons_collec_goods_gen)
        addChildClickViewIds(R.id.iv_collect_addcart)

        addChildClickViewIds(R.id.cb_collect_shop_check)
        addChildClickViewIds(R.id.tv_collect_shop_delete)
        addChildClickViewIds(R.id.cons_collect_shop_gen)
    }


    override fun convert(holder: BaseDataBindingHolder<*>, item: MultiItemEntity) {
        when (item.itemType) {
            0 -> {
                setGoodsView(holder, item as AbsGoodsModel, holder.dataBinding as GoodsitemCollectBinding)
            }
            1 -> {
                setShopView(holder, item as AbsShopModel, holder.dataBinding as ItemCollectShopAdapterBinding)
            }
        }
    }

    fun setGoodsView(helper: BaseViewHolder, model: AbsGoodsModel, itemCollectGoodsAdapterBinding: GoodsitemCollectBinding) {
        itemCollectGoodsAdapterBinding.model = model
        itemCollectGoodsAdapterBinding.isShowDelete = isShowDelete

    }

    fun setShopView(helper: BaseViewHolder, model: AbsShopModel, itemCollectShopAdapterBinding: ItemCollectShopAdapterBinding) {
        itemCollectShopAdapterBinding.model = model
        itemCollectShopAdapterBinding.isShowDelete = isShowDelete

    }

}